package com.hj.file.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;

/**
 * pdfpox 操作pdf
 */
public class PDFPoxUtil {
    public static void readPdf(InputStream inputStream) throws IOException {
//        PDDocument pdDocument = PDDocument.load(inputStream);
//        PDFTextStripper stripper = new PDFTextStripper();
//        String contents = stripper.getText(pdDocument);
//        pdDocument.close();
    }
    public static void readPdfImage(){
//        PDDocument document = PDDocument.load(new FileInputStream(filename));
//        List<PDPage> pages = document.getDocumentCatalog().getAllPages();
//        Iterator<PDPage> iter = pages.iterator();
//        int count = 0;
//        while (iter.hasNext()) {
//            PDPage page = (PDPage) iter.next();
//            PDResources resources = page.getResources();
//            Map<String, PDXObjectImage> images = resources.getImages();
//            if (images != null) {
//                Iterator<String> imageIter = images.keySet().iterator();
//                while (imageIter.hasNext()) {
//                    count++;
//                    String key = (String) imageIter.next();
//                    PDXObjectImage image = (PDXObjectImage) images.get(key);
//                    String name = "ss_" + count;    // 图片文件名
//                    image.write2file(imagePath + name);        // 保存图片
//                }
//            }
//        }
    }
}
